<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/tags/trymore" prefix="tm"%>

<script type="text/javascript">
	$(function(){
		$.each($("textarea", $("#formMat")), function(){
			$(this).html($(this).text().replace(/<br\/>/g,"\n"));
		});
	});
	
	function ajaxDone_callback () {
		// 重新加载当前弹框页面数据
		if ($.pdialog._current != null) {
			$.pdialog.reload("app/flow/material.do?action=dialogFlowMaterialConfPage&rootId=${parent.id}");
		}
	}	
	
	function table_sort() {
		if ($("#tbl_flowseqs").find("tr").size() > 1) {
			$("#tbl_flowseqs").tablesorter({ 
				// set forced sort on the fourth column and i decending order. 
				sortList: [[0,0]] 
			});
		}
	}
	
	function dialogAjaxDone_MTP () {
		// 重新加载当前弹框页面数据
		var dialogs = $(".dialog");
		if ($.pdialog._current != null) {
			if (dialogs.length > 1) {
				$.pdialog.switchDialog($(dialogs[dialogs.length - 2]));
				$.pdialog.close($(dialogs[dialogs.length - 1]));
			} else {
				$.pdialog.closeCurrent();
			}
			
			$.pdialog.reload("app/flow/material.do?action=dialogFlowMaterialConfPage&rootId=${entity ne null ? entity.materialParent.id : (parent ne null ? parent.id : '-1')}");
		}
	}
</script>

<div class="pageContent">
	<form method="post" action="app/flow/material.do?action=actionSaveFlowMaterial" class="pageForm required-validate" onsubmit="return validateCallback(this, ${parent ne null || (entity ne null && entity.materialParent ne null) ? 'dialogAjaxDone_MTP' : 'dialogAjaxDone'});" id="formMat">
		<div class="pageFormContent" layoutH="56">
			<table cellspacing="10" cellpadding="10" class="dform">
				<c:if test="${parent ne null}">
					<tr>
						<td>材料分类：</td>
						<td><input type="text" value="${parent.materialName}" style="width: 88%" readonly /></td>
					</tr>
				</c:if>
				<tr>
					<td>${parent ne null ? '材料名称' : '材料分类'}：</td>
					<td><input name="materialName" type="text" size="30" value="${entity ne null ? entity.materialName : ''}" class="required" style="width: 88%" /></td>
				</tr>
				<c:if test="${parent ne null}">
					<tr>
						<td>材料性质：</td>
						<td>
							<select class="combox required" name="materialType" id="dialog_matType">
								<option value="">请选择材料性质</option>
								<option value="1" ${entity ne null && entity.materialType eq 1 ? 'selected' : ''}>必须提交</option>
								<option value="0" ${entity ne null && entity.materialType eq 0 ? 'selected' : ''}>建议提交</option>
							</select>
						</td>
					</tr>
				</c:if>
				<tr>
					<td style="vertical-align: top;">${parent ne null ? '材料描述' : '分类描述'}：</td>
					<td>
						<textarea rows="2" cols="40" name="materialDesc" class="textInput" style="width: 88%">${entity ne null ? entity.materialDesc : ''}</textarea>
					</td>
				</tr>
			</table>
		</div>
		<div class="formBar">
			<ul>
				<li>
					<div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div>
				</li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
		<input type="hidden" name="id" value="${entity ne null ? entity.id : '-1'}" />
		<input type="hidden" name="rootId" value="${entity ne null ? entity.materialParent.id : (parent ne null ? parent.id : '-1')}" />
	</form>
<div>